/**
 * Created by Administrator on 2017/6/27.
 */
define(['jquery', 'vue', 'mui'], function ($, Vue, mui) {
    mui.init();
    var vue = new Vue({
        el: '#order_div',
        data: {
            items: [],
            info: []
        },
        methods: {
            order_pay: function (id,send_status) {
                if (send_status.code === 1) {
                    // mui.alert("配送费5元起", '系统提示', function () {
                    //     window.location.href = order_pay_url + "/order_id/" + id;
                    // }, 'div');
                    mui.confirm('配送费5元起', '系统提示', ['取消', '确定'], function (e) {
                        if (e.index === 1) {
                            window.location.href = order_pay_url + "?order_id=" + id+"&back_url=" + c_url;
                        }
                    });
                }
                else {
                    mui.alert(send_status.msg);
                }

            },
            take_order: function (id) {//货到付款收款
                mui.confirm('您确定收到货了吗？', '', ['取消', '确定'], function (e) {
                    if (e.index === 1) {
                        $.post(take_order_url, {order_id: id},
                            function (result) {
                                if (result.code === 1) {
                                    mui.alert("已确认收货!", '系统提示', function () {
                                        location.reload();
                                    }, 'div');
                                } else {
                                    mui.alert(result.msg);
                                }
                            });
                    }
                });
            },
            cancel_order: function (id) {
                mui.confirm('您确定取消该订单吗？', '', ['取消', '确定'], function (e) {
                    if (e.index === 1) {
                        $.post(cancel_order_url, {order_id: id}, function (res) {
                            if (res.code === 1) {
                                mui.alert("订单已取消!", '系统提示', function () {
                                    location.reload();
                                }, 'div');
                            } else {
                                mui.alert('网络出错，请稍后再试');
                            }
                        })
                    }
                })
            }
        }
    });
    getData();
    function getData() {
        $.get(list_url, {order_id: order_id},
            function (result) {
                if (result.code === 1) {
                    vue.items = result.data.list;
                    vue.info = result.data.info;
                }
            });
    }

});